import React from 'react'
import ProForm, { ProFormGroup, ProFormRadio } from '@ant-design/pro-form'
import EditorDemo from '@/components/Editor'

function Radio (props) {
  const { setDetails, questionDetails } = props

  return (
    <>
      {/* 正确答案 */}
      <ProFormRadio.Group
        label="正确答案"
        required
        name="success_answer"
        initialValue={questionDetails.success_answer === undefined ? '' : parseInt(questionDetails.success_answer)}
        options={[
          {
            label: '错误',
            value: 0
          },
          {
            label: '正确',
            value: 1
          },
        ]}/>
      {/* 答案解析 */}
      <ProFormGroup>
        <ProForm.Item
          label="答案解析"
          required name="analysis"
          initialValue={questionDetails.analysis === undefined ? '' : questionDetails.analysis}
        >
          <EditorDemo
            setDetails={setDetails}
            name="analysis"
            content={questionDetails.analysis === undefined ? '' : questionDetails.analysis}
          />
        </ProForm.Item>
      </ProFormGroup>
    </>
  )
}

export default Radio
